package com.vhall.component.entity.room.enums;

import com.vhall.component.entity.dictionary.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 业务权限-
 *
 * @author xing.wang
 * @date 2023/8/7
 */
@Getter
@AllArgsConstructor
public enum BusinessAuthEnum implements BaseEnum {
    NO_REQUIREMENT("0", 0, "无要求"),
    FINANCING_MARGIN("1", 1,"融资融券"),
    CHINEXT("E", 2,"创业板"),
    STOCK_OPTIONS("w", 3,"股票期权"),
    BEIJING_STOCK_EXCHANGE("x",4, "北交所"),
    STAR_MARKET("k", 5,"科创板"),
    HONGKONG_STOCK_CONNECT("^", 6,"港股通");
    private final String value;

    private final Integer code;
    private final String name;
    @Override
    public String getValue() {
        return value;
    }

    public Integer getCode(){
        return code;
    }
    @Override
    public String getName() {
        return name;
    }
    /**
     * 通过 value 获取 name
     * @param value
     * @return
     */
    public static String getNameByValue(String value) {
        for (BusinessAuthEnum e : BusinessAuthEnum.values()) {
            if (e.getValue().equals(value)) {
                return e.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByValue(String value) {
        for (BusinessAuthEnum e : BusinessAuthEnum.values()) {
            if (e.getValue().equals(value)) {
                return e.getCode();
            }
        }
        return null;
    }
}
